<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="initial-scale=1, user-scalable=0, minimal-ui" charset="UTF-8">
		<title></title>
		<link rel="stylesheet" href="css/index.css" />
		<link rel="stylesheet" href="css/swiper.css" />
		<link rel="stylesheet" href="css/mint.css">
	</head>
	<script src="js/serverUrl.js"></script>
	<script src="js/vue.js"></script>
	<script src="js/mint.js"></script>
	<script src="js/moment.js"></script>
	<body>
		<div id="app">
			
			<mt-swipe  style="height: 40vw;" :auto="4000">
			  <mt-swipe-item v-for="item in imageList"> <img  class="swiper-slide" :src="item"></mt-swipe-item>
			</mt-swipe>
			
			<div id="table" class="card">
				<div v-for="(news,index) in newsList">
					<div v-if="news.listDataType == 2"  class="jinengNews" v-on:click="toNewsDetail(news.dataId)">
						<div class="newsTitle"><span class="newsTitleSpan" :style="{'color':news.color,'border-color':news.color}">{{news.type}}</span>{{news.title}}</div>
						<div class="author">作者：{{news.author}} <span class="newsDate">{{news.showTime}}</span></div>
					</div>
					<div v-if="news.listDataType == 6"  class="jinengVideo"  v-on:click="toVideoDetail(index)">
						<div  class="videoInfo">
							<div class="newsTitle"><span class="newsTitleSpan" :style="{'color':news.color,'border-color':news.color}">{{news.type}}</span>{{news.title}}</div>
							<div class="videoAuthor">作者：{{news.author}}</div>
						</div>
						<div>
							<img class="videoImage" :src="serverUrl+news.coverUrl" />
						</div>
					</div>
					<div v-if="news.listDataType == 5" class="jinnengTopic" v-on:click="toTopicDetail(news.dataId)">
						<div class="newsTitle">{{news.title}}</div>
						<img class="topicImage" :src="serverUrl+news.coverUrl" />
						<div class="author">作者：{{news.author}} <span class="newsDate">{{news.showTime}}</span></div>
					</div>
				</div>
			</div>
		</div>
	</body>
	
	<script type="text/javascript">
		var app = new Vue({
		  el: '#app',
		  data: {
		   imageList: [],
		   newsList:[]
		  },
          created () {
              window.getNewsList = this.getNewsList
              window.clear = this.clear
              window.getImageList = this.getImageList
          },
		  methods:{
              getImageList (imageList) {
                  this.imageList = imageList
              },
              getNewsList (newsList) {
                  for(let i=0;i<newsList.length;i++){
                      let moudleInfo = JSON.parse(newsList[i].module)[0]

                      newsList[i].color = "#F44336"
                      newsList[i].type = '晋能在线'
                      newsList[i].showTime = moment(newsList[i].pushDate).format("YYYY-MM-DD")
                      if(JSON.stringify(moudleInfo) == "[1,2]") {
                          newsList[i].color = "#F44336"
                          newsList[i].type = '安全学习'
                      }
                      if(JSON.stringify(moudleInfo) == "[1,3]") {
                          newsList[i].color = "#2196F3"
                          newsList[i].type = '岗位技能'
                      }
                      if(JSON.stringify(moudleInfo) == "[1,4]") {
                          newsList[i].color = "#FF9800"
                          newsList[i].type = '管理改善'
                      }
                      if(JSON.stringify(moudleInfo) == "[1,5]") {
                          newsList[i].color = "#4CAF50"
                          newsList[i].type = '精品课程'
                      }
                      if(JSON.stringify(moudleInfo) == "[6,8]") {
                          newsList[i].color = "#F44336"
                          newsList[i].type = '企业风采'
                      }
                      if(JSON.stringify(moudleInfo) == "[6,12]") {
                          newsList[i].color = "#4CAF50"
                          newsList[i].type = '学习视频'
                      }
                      if(JSON.stringify(moudleInfo) == "[9,11]") {
                          newsList[i].color = "#2196F3"
                          newsList[i].type = '讲话通知'
                      }
                      if(JSON.stringify(moudleInfo) == "[9,10]") {
                          newsList[i].color = "#4CAF50"
                          newsList[i].type = '行业快讯'
                      }
                      if(JSON.stringify(moudleInfo) == "[9,14]") {
                          newsList[i].color = "#F44336"
                          newsList[i].type = '企业要闻'
                      }
                      if(JSON.stringify(moudleInfo) == "[9,15]") {
                          newsList[i].color = "#FF9800"
                          newsList[i].type = '法律法规'
                      }
                      if(JSON.stringify(moudleInfo) == "[15,16]") {
                          newsList[i].color = "#2196F3"
                          newsList[i].type = '能工巧匠'
                      }
                      this.newsList.push(newsList[i])
                  }
              },
              clear() {
                  this.newsList = []
              },
			  toNewsDetail (dataId){
                var params = {
                    newsId:dataId
                }
                toNewsDetailViewController(JSON.stringify(params))
			  },
              toVideoDetail (index) {
                  let news = this.newsList[index]
                  toVideoDetailViewController(news.dataId,news.coverUrl)
              },
              toTopicDetail (dataId) {
                  toTopicDetailViewController(dataId)
              }
		  }
		})
	</script>
</html>
